package com.stk.doublebreak;

import org.andengine.entity.particle.emitter.BaseParticleEmitter;
import org.andengine.entity.particle.emitter.PointParticleEmitter;
import org.andengine.entity.particle.modifier.ColorParticleModifier;
import org.andengine.entity.primitive.Line;
import org.andengine.entity.shape.IShape;
import org.andengine.entity.sprite.Sprite;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;
import org.andengine.util.color.Color;

import android.graphics.Point;

public class Player extends Line{
	
	private Line shadow;
	private Smoke leftSmoke;
	private Smoke rightSmoke;
	private int colorShape;
	
	public Player(VertexBufferObjectManager pVertexBufferObjectManager, ITextureRegion mParticleTextureRegion, int level, int width, int height){
		super(0,0,0,0,3,pVertexBufferObjectManager);
		
		shadow =  new Line(0, 0, 0, 0, 8, pVertexBufferObjectManager);		
		
		this.leftSmoke = new Smoke(new PointParticleEmitter(9999999, 9999999), 50,60, 60, mParticleTextureRegion, pVertexBufferObjectManager, level, width, height);
		this.rightSmoke = new Smoke(new PointParticleEmitter(9999999, 9999999), 50,60, 60, mParticleTextureRegion, pVertexBufferObjectManager, level, width, height);		
		this.changeColor(2);
	}

	@Override
	public void setPosition(float pX1, float pY1, float pX2, float pY2) {
		super.setPosition(pX1, pY1, pX2, pY2);		
		this.shadow.setPosition(pX1, pY1, pX2, pY2);
		((BaseParticleEmitter)this.leftSmoke.getParticleEmitter()).setCenter(pX1, pY1);
		((BaseParticleEmitter)this.rightSmoke.getParticleEmitter()).setCenter(pX2, pY2);
	}
	
	public void changeColor(int c){
		float r = 0f;
		float g = 0f;
		float b = 0f;
		this.colorShape = c + 3;
		Color shadowColor = Util.HexToRGB("#FFFFFF");
		Color mainColor = Util.HexToRGB("#CCCCCC");
		
		switch(c){
		case 0: 	shadowColor =Util.HexToRGB("#CC0000");
			  		mainColor = Util.HexToRGB("#FF4444");
			  		r = Util.HexToR("CC");
			  		g = Util.HexToR("00");
			  		b = Util.HexToR("00");
			  		break;
		case 1: 	shadowColor =Util.HexToRGB("#FF8800");
			  		mainColor = Util.HexToRGB("#FFBB33");
			  		r = Util.HexToR("FF");
			  		g = Util.HexToR("88");
			  		b = Util.HexToR("00");
			  		break;
		case 2: 	shadowColor =Util.HexToRGB("#669900");
			  		mainColor = Util.HexToRGB("#99CC00");
			  		r = Util.HexToR("66");
			  		g = Util.HexToR("99");
			  		b = Util.HexToR("00");
			  		break;
		case 3: 	shadowColor =Util.HexToRGB("#9933CC");
			  		mainColor = Util.HexToRGB("#AA66CC");
			  		r = Util.HexToR("99");
			  		g = Util.HexToR("33");
			  		b = Util.HexToR("CC");
			  		break;			
		}	
		
		this.shadow.setColor(shadowColor);
		this.setColor(mainColor);
		
		this.leftSmoke.setColorModifier(new ColorParticleModifier<Sprite>(0f, 0f,r,r,g,g,b,b));
		this.rightSmoke.setColorModifier(new ColorParticleModifier<Sprite>(0f, 0f,r,r,g,g,b,b));
	}

	public Line getShadow() {
		return shadow;
	}

	public Smoke getLeftSmoke() {
		return leftSmoke;
	}

	public Smoke getRightSmoke() {
		return rightSmoke;
	}
	
	public int getColorShape(){
		return colorShape;
	}
	
}
